// 全部课程
const courseLinks = document.querySelectorAll('.courseLink');
document.addEventListener('click', (event) => {
    courseLinks.forEach(courseLink => {
        const subElement = courseLink.nextElementSibling;
        const iconElement = courseLink.querySelector('i');
        if (courseLink.contains(event.target) || subElement.contains(event.target)) {
            return;
        }
        subElement.style.display = 'none';
        iconElement.style.transform = 'rotate(0deg)';
        if (window.location.hostname !== 'https://www.atxunda.com') {
            document.body.style.overflow = 'auto';
        }
    });
});

courseLinks.forEach(courseLink => {
    const subElement = courseLink.nextElementSibling;
    const iconElement = courseLink.querySelector('i');

    courseLink.addEventListener('click', () => {
        if (subElement.style.display === 'block') {
            subElement.style.display = 'none';
            iconElement.style.transform = 'rotate(0deg)';
            if (window.location.hostname !== 'https://www.atxunda.com') {
                document.body.style.overflow = 'auto';
            }
        } else {
            subElement.style.display = 'block';
            iconElement.style.transform = 'rotate(180deg)';
            if (window.location.hostname !== 'https://www.atxunda.com') {
                document.body.style.overflow = 'hidden';
            }
        }
    });

    subElement.addEventListener('click', (event) => {
        event.stopPropagation();
    });
});
courseLinks.forEach(courseLink => {
    const subElement = courseLink.nextElementSibling;
    const iconElement = courseLink.querySelector('i');

    courseLink.addEventListener('click', () => {
        if (subElement.style.display === 'block') {
            subElement.style.display = 'none';
            iconElement.style.transform = 'rotate(0deg)';
        } else {
            subElement.style.display = 'block';
            iconElement.style.transform = 'rotate(180deg)';
        }
    });
    subElement.addEventListener('click', (event) => {
        event.stopPropagation();
    });
});
const userDropdown = document.querySelectorAll('.user-dropdown');
userDropdown.forEach(userDropdown => {
    const subElement = userDropdown.nextElementSibling;
    userDropdown.addEventListener('mouseover', () => {
        subElement.style.display = 'block';
    });
    userDropdown.addEventListener('mouseout', (event) => {
        if (!subElement.contains(event.relatedTarget)) {
            subElement.style.display = 'none';
        }
    });
    subElement.addEventListener('mouseover', () => {
        subElement.style.display = 'block';
    });
    subElement.addEventListener('mouseout', () => {
        subElement.style.display = 'none';
    });
});
const element = document.getElementById("head");
if(element){
    element.addEventListener("mouseover", function () {
        element.classList.add("head-white");
    });
    element.addEventListener("mouseout", function () {
        element.classList.remove("head-white");
    });
}
